% This is part of the book TeX for the Impatient.
% Copyright (C) 2003 Paul W. Abrahams, Kathryn A. Hargreaves, Karl Berry.
% See file fdl.tex for copying conditions.

% Fonts for TeX for the Impatient.

% This file is being distributed with the macros because the macro file
% refers to it.  We used a combination of Bitstream and standard TeX
% fonts for the original printed book, but for the free edition, we
% stick to Computer Modern.
% -----------------------------------------------------------------------
% 
% We used Computer Modern for the main text and math, and Zapf Humanist
% (i.e., Optima) for heads.  (bs00015 is Optima Roman, 16 italic, 17
% bold, 18 bold italic.)  
% 
% First we define all of the fonts we use for any purpose, in terms of the
% font files.  Later we define fonts functionally, using \let or \def.

% Computer Modern fonts.
%
\chardef\chinesefont = 2
\ifcase\chinesefont
  \def\song{Adobe Song Std}
  \def\hei{Adobe Heiti Std}
  \def\kai{Adobe Kaiti Std}
  \def\fang{Adobe Fangsong Std}
\or
  \def\song{SimSun}
  \def\hei{SimHei}
  \def\kai{KaiTi}
  \def\fang{FangSong}
\or
  \def\song{FandolSong}
  \def\hei{FandolHei}
  \def\kai{FandolKai}
  \def\fang{FandolFang}
\fi
%
\newif\ifxecjk \xecjktrue
\ifxecjk
  \font\CJKfont="\song" at 10pt
  \input xeCJK-base
  \def\letfont{\let\CJKfont}
  \xeCJKenablechecksingle
  \normalspacedchars{-}
\else
  \font\zhfont="\song" at 10pt
  \def\zhpunctfont{\zhfont}
  \input zhspacing.sty
  \zhspacing
  \def\letfont{\let\zhfont}
\fi
%
\font\enfiverm = cmr5
\font\zhfiverm = "\song" at 5pt
\def\fiverm{\enfiverm\letfont\zhfiverm}
\font\eneightrm = cmr8
\font\zheightrm = "\song" at 8pt
\def\eightrm{\eneightrm\letfont\zheightrm}
\font\enninerm = cmr9 % Glue pictures, small caps for ASCII.
\font\zhninerm = "\song" at 9pt
\def\ninerm{\enninerm\letfont\zhninerm}
%\font\tenrm = xcmr10 % with our kerning
\font\entenrm = cmr10 % don't have the xcmr10 source any more
\font\zhtenrm = "\song"  at 10pt
\def\tenrm{\entenrm\letfont\zhtenrm}
\font\enoldtenrm = cmr10 % straight CM
\font\zholdtenrm = "\song"  at 10pt
\def\oldtenrm{\enoldtenrm\letfont\zholdtenrm}
\font\entwelverm = cmr12
\font\zhtwelverm = "\song"  at 12pt
\def\twelverm{\entwelverm\letfont\zhtwelverm}
\font\entwentysixrm = cmr10 at 26pt
\font\zhtwentysixrm = "\hei"  at 26pt
\def\twentysixrm{\entwentysixrm\letfont\zhtwentysixrm}
%
\font\eneightit = cmti8
\font\zheightit = "\kai" at 8pt
\def\eightit{\eneightit\letfont\zheightit}
\font\ennineit = cmti9
\font\zheightit = "\kai" at 9pt
\def\nineit{\ennineit\letfont\zhnineit}
\font\entenit = cmti10
\font\zhtenit = "\kai" at 10pt
\def\tenit{\entenit\letfont\zhtenit}
%
\font\eneighttt = cmtt8
\font\zheighttt = "\fang" at 8pt
\def\eighttt{\eneighttt\letfont\zheighttt}
\font\ententt = cmtt10
\font\zhtentt = "\fang" at 10pt
\def\tentt{\ententt\letfont\zhtentt}
\font\eneleventt = cmtt10 at 11pt
\font\zheleventt = "\fang" at 11pt
\def\elventt{\enelventt\letfont\zhelventt}
\font\entwelvett = cmtt10 scaled \magstep2
\font\zhtwelvett = "\fang" at 12pt
\def\twelvett{\entwelvett\letfont\zhtwelvett}
%
\font\entenbt = cmtt10
\font\zhtenbt = "\fang" at 10pt
\def\tenbt{\entenbt\letfont\zhtenbt}
%
\font\enelevensf = cmss10 scaled\magstephalf
\font\zhelevensf = "\hei" at 11pt
\def\elevensf{\enelevensf\letfont\zhelevensf}
\font\enfourteensf = cmss10 scaled\magstep2
\font\zhfourteensf = "\hei" at 14pt
\def\fourteensf{\enfourteensf\letfont\zhfourteensf}
%
\font\eneightbf = cmbx8
\font\zheightbf = "\hei" at 8pt
\def\eightbf{\eneightbf\letfont\zheightbf}
\font\entenbf = cmbx10
\font\zhtenbf = "\hei" at 10pt
\def\tenbf{\entenbf\letfont\zhtenbf}
\font\enelevenbf = cmbx10 scaled \magstephalf
\font\zhelevenbf = "\hei" at 11pt
\def\elevenbf{\enelevenbf\letfont\zhelevenbf}
\font\entwelvebf = cmbx12
\font\zhtwelvebf = "\hei" at 12pt
\def\twelvebf{\entwelvebf\letfont\zhtwelvebf}
\font\enthirtysixbf = cmbx10 at 36pt
\font\zhthirtysixbf = "\hei" at 36pt
\def\thirtysixbf{\enthirtysixbf\letfont\zhthirtysixbf}
%
\font\entenbi = cmbxti10
\font\zhtenbi = "\hei" at 10pt
\def\tenbi{\entenbi\letfont\zhtenbi}
\font\enelevenbi= cmbxti10 scaled \magstephalf
\font\zhelevenbi = "\hei" at 11pt
\def\elevenbi{\enelevenbi\letfont\zhelevenbi}
\font\enfourteenbi= cmbxti10 scaled \magstep2
\font\zhfourteenbi = "\hei" at 14pt
\def\fourteenbi{\enfourteenbi\letfont\zhfourteenbi}
%
\font\entensc = cmcsc10
\font\zhtensc = "\fang" at 10pt
\def\tensc{\entensc\letfont\zhtensc}
\font\eneightsl = cmsl8
\font\zheightsl = "\fang" at 8pt
\def\eightsl{\eneightsl\letfont\zheightsl}
\font\eneighti = cmmi8
\font\zheighti = "\kai" at 8pt
\def\eighti{\eneighti\letfont\zheighti}
\font\eneightsy = cmsy8
\font\zheightsy = "\song" at 8pt
\def\eightsy{\eneightsy\letfont\zheightsy}

% % Optima fonts.
% %
% \font\eightopt = bs0015 at 8pt
% \font\nineopt = bs0015 at 9pt
% \font\twelveopt = bs0015 at 12pt
% \font\twentysixopt = bs0015 at 26pt
% \font\nineoptit = bs0016 at 9pt
% \font\tenoptit = bs0016 at 10pt
% \font\tenoptbf = bs0017 at 10pt
% \font\thirtysixoptbf = bs0017 at 36pt
% \font\tenbt = bs00175 at 10pt
% \font\tenoptbi = bs0018 at 10pt
% \font\elevenoptbi = bs0018 at 11pt
% \font\fourteenoptbi = bs0018 at 14pt
 
% Palatino fonts.
%
\font\tenpal = pplr
%\font\tenpal = bs0023
%\font\tenpalit = bs0024
%\font\tenpalbf = bs0025
%\font\tenpalbi = bs0026

% Logo and picture fonts.
% 
\font\eightlogo = logo8
\font\logosl = logosl10
\font\handfont = pzdr

% The following changes are to avoid driver overflow
\ifmsdos
   \font\cnum = cnum % 36-pt bold Optima, numbers only (just for MS-DOS)
   \let\chapternumeralfont = \cnum
   %\let\thirtysixoptbf = \twentysixopt
   %\font\sevensy = cmsy8
   %\font\seveni = cmmi8
\fi

\def\undefinedfont{\errmessage{Undefined font}}

% This should only be called when \rm et al. are going to be defined
% directly.
% 
\def\clearfonts{\let\rm = \undefinedfont \let\bf = \undefinedfont
   \let\it = \undefinedfont \let\bi = \undefinedfont
   \let\tt = \undefinedfont \let\bt = \undefinedfont
   \let\sc = \undefinedfont
   \let\ss = \undefinedfont
}

% We only need to assign to \fam if the font is going to be used in math
% mode, which isn't the case with any of these.  \rm, \it, \sl, \bf, and
% \tt are defined in plain.
% 
\def\bi{\tenbi}

\def\mapquotes{\catcode`` = \active \catcode`' = \active}
{\mapquotes
  \gdef\bt{% The font change also draws \ ` ' from a different font.
     \tenbt
     \def\\{{\tentt \char92}}%
     \def`{{\tentt \char96}}\def'{{\tentt \char39}}%
  }
}

\def\bti{\tenbi}
\def\sc{\tensc}

% Text fonts.
% 
\def\textfonts{%
  \def\rm{\fam0\tenrm}%
  \textfont0=\tenrm \scriptfont0=\sevenrm \scriptscriptfont0=\fiverm
  \textfont1=\teni \scriptfont1=\seveni \scriptscriptfont1=\fivei
  \textfont2=\tensy \scriptfont2=\sevensy \scriptscriptfont2=\fivesy
  \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
  \def\it{\fam\itfam\tenit}\textfont\itfam=\tenit
  \def\sl{\fam\slfam\tensl}\textfont\slfam=\tensl
  \def\bf{\fam\bffam\tenbf}\textfont\bffam=\tenbf
  \scriptfont\bffam=\sevenbf \scriptscriptfont\bffam=\fivebf
  \def\tt{\fam\ttfam\tentt}\textfont\ttfam=\tentt
  \let\sc = \tensc
  \setbox\strutbox=\hbox{\vrule height8.5pt depth3.5pt width\z@}%
  \normalbaselineskip=12pt
  \normalbaselines \rm
}


% Footnote fonts.  We generally use eight point.
% 
\def\footnotefonts{%
  \def\rm{\fam0\eightrm}%
  \textfont0=\eightrm \scriptfont0=\sevenrm \scriptscriptfont0=\fiverm
  \textfont1=\eighti \scriptfont1=\seveni \scriptscriptfont1=\fivei
  \textfont2=\eightsy \scriptfont2=\sevensy \scriptscriptfont2=\fivesy
  \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
  \def\it{\fam\itfam\eightit}\textfont\itfam=\eightit
  \def\sl{\fam\slfam\eightsl}\textfont\slfam=\eightsl
  \def\bf{\fam\bffam\eightbf}\textfont\bffam=\eightbf
  \scriptfont\bffam=\sevenbf \scriptscriptfont\bffam=\fivebf
  \def\tt{\fam\ttfam\eighttt}\textfont\ttfam=\eighttt
  \let\sc = \eightsc
  \setbox\strutbox=\hbox{\vrule height7pt depth2pt width\z@}%
  \normalbaselineskip=9pt
  \normalbaselines \rm
}

% Fonts for the example titles.  They are defined in the first example,
% also.
% 

\def\exampletitlefonts{\clearfonts 
   \let\bf = \elevenbf
   \let\bi = \elevenbi
   \baselineskip = 13pt \bf
}

% Fonts for the subsection titles.
% 
\def\subsectionfonts{\clearfonts \let\sf = \elevensf
   \baselineskip = 12pt \sf
}


% Fonts for the section titles.
% 
\def\sectionfonts{\clearfonts \let\sf = \fourteensf
   \baselineskip = 16pt \sf
}

% Fonts for the chapter titles.
% 
\let\chapternumeralfont = \thirtysixbf

\def\chapterfonts{\clearfonts \let\bf = \twentysixrm
   \baselineskip = 32pt \bf
}

% Fonts for the table of contents.
% 
\def\shorttocfonts{\clearfonts \let\rm = \twelverm
   \baselineskip = 20pt \rm
}

\def\tocfonts{\clearfonts \let\rm = \ninerm
   \let\it = \tenit \let\bf = \tenbf
   \baselineskip = 12pt \rm
}

% Fonts for the index.
% 

\def\indexfonts{\clearfonts
   \let\rm = \eightrm
   \let\it = \eightit
   \let\tt = \eighttt
   \let\sc = \tensc
   \let\sl = \eightsl
   \textfont2 = \eightsy % For \AMSTeX.
   \let\mflogo = \eightlogo % For \Metafont.
   \normalbaselineskip = 10pt \normallineskip = 1.5pt \normalbaselines
   \setbox\strutbox=\hbox{\vrule height 7.5pt depth2.5pt width0pt}%
   \rm
}

% Fonts for the inside back cover.
% 
\def\conceptpagefonts{\clearfonts
   \let\rm = \ninerm
   \let\sc = \eightrm
   \let\sl = \nineit
   \baselineskip = 12pt
   \rm
}

% We don't want any automatic hyphenation within the code font

\hyphenchar\zhtentt = -1
\hyphenchar\ententt = -1
\hyphenchar\zheighttt = -1
\hyphenchar\eneighttt = -1



\textfonts
